define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'user.withdrawal/index',
        add_url: 'user.withdrawal/add',
        edit_url: 'user.withdrawal/edit',
        delete_url: 'user.withdrawal/delete',
        export_url: 'user.withdrawal/export',
        modify_url: 'user.withdrawal/modify',
        verify_url: 'user.withdrawal/verify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh','export'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'nickname', title: '申请用户',search: false},
                    {field: 'before_total_income', title: '提现前总收入',search: false},
                    {field: 'before_availble_income', title: '提现前剩余可提现收益',search: false},
                    {field: 'amount', title: '申请金额',search: false},
                    {field: 'state', title: '状态',search: 'select',selectList: {
                        0: '申请中',
                        '-1': '审核失败',
                        1: '审核通过'
                    },
                        templet: function(d){
                            if(d.state == 0){return "申请中"}
                            if(d.state == -1){return "审核失败"}
                            if(d.state == 1){return "审核通过"}
                        }
                    },
                    {field: 'msg', title: '审核结果描述',search: false},
                    {field: 'create_time', title: '申请时间',search: false},
                    {field: 'verify_time', title: '确认时间',search: false},
                    {width: 250, title: '操作', 
                        templet: function (row) {
                        return ea.table.tool(row, {
                            init, // 初始化的数据变量
                            operat: [
                                [{
                                    text: '审核',
                                    url: init.verify_url,
                                    method: 'open',
                                    auth: 'verify',
                                    class: 'layui-btn layui-btn-xs layui-btn-success',
                                    extend: 'data-full="true"',
                                },],
                            ]
                        })
                     },
                    },
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        verify: function () {
            ea.listen();
        },
    };
    return Controller;
});